
//
//  STServiceManageVC.m
//  YiYueHairdresser
//
//  Created by zhouzhouzhou on 2018/9/30.
//  Copyright © 2018年 YuYiLian. All rights reserved.
//

#import "STServiceManageVC.h"

#import "MLMSegmentManager.h"
#import "STAddServiceSelVC.h"
#import "STServiceListVC.h"

@interface STServiceManageVC (){
    NSArray * arrTopBars;
}

@end

@implementation STServiceManageVC

- (void)viewDidLoad {
    [super viewDidLoad];
    arrTopBars =@[@"接单中", @"未上架"];
    self.navigationItem.title = @"服务管理";
    [self wr_setNavBarTintColor:[UIColor blackColor]];
    UIBarButtonItem *rightBarBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(actionService)];
    self.navigationItem.rightBarButtonItem = rightBarBtn;
    
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    
    MLMSegmentHead *segHead = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, 40) titles:arrTopBars headStyle:SegmentHeadStyleLine layoutStyle:MLMSegmentLayoutDefault];
    
    MLMSegmentScroll * serScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, 40+64, SCREEN_WIDTH, SCREEN_HEIGHT-40-64) vcOrViews:[self getServiceViewsWithCount:arrTopBars.count]];
//    serScroll.segDelegate = self;
    
    [MLMSegmentManager associateHead:segHead withScroll:serScroll completion:^{
        [self.view addSubview:segHead];
        [self.view addSubview:serScroll];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}

-(NSArray *)getServiceViewsWithCount:(NSInteger)count{
    NSMutableArray * arr = [NSMutableArray arrayWithCapacity:count];
    for (int i = 0; i<count; i++) {
        STServiceListVC * listView = [[STServiceListVC alloc]init];
        listView.view.frame = CGRectMake(0, 35, SCREEN_WIDTH, SCREEN_HEIGHT-35-64);
        listView.type = i;
        [arr addObject:listView];
    }
    return  arr;
}



//添加服务
-(void)actionService{
    
    STAddServiceSelVC * addVC = [STAddServiceSelVC new];
    addVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:addVC animated:NO];
    
}

@end
